<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<s:iterator value="proInfoList" id="list">
    <li id="<s:property value="#list.id"/>">
        <a data-ajax="false" key="ajax_proinfo_listview_actions_select">
	        <span class="h2"><s:property value="#list.name" /></span>
            <p>
                <s:property value="#list.chief.name" />
                <span>[<s:property value="#list.province" />]</span>
            </p>
        </a>
    </li>
</s:iterator>

<input type="hidden" id="latitude" name="latitude" value="" />
<input type="hidden" id="longitude" name="longitude" value="" />
<input type="hidden" name="pageKeyword" value="<s:property value="pager.pageKeyword"/>" />
<input type="hidden" name="pageNumber" value="<s:property value="pager.pageNumber"/>" />
<input type="hidden" name="pageCount" value="<s:property value="pager.pageCount"/>" />
<input type="hidden" name="totalCount" value="<s:property value="pager.totalCount"/>" />
<input type="hidden" name="pageKeyword1" value="<s:property value="pager.pageKeyword"/>" />
<input type="hidden" name="pageNumber1" value="<s:property value="pager.pageNumber"/>" />
<input type="hidden" name="pageCount1" value="<s:property value="pager.pageCount"/>" />
<input type="hidden" name="totalCount1" value="<s:property value="pager.totalCount"/>" />
<script type="text/javascript">

    $(function(){
        var lis = $("a[key=ajax_proinfo_listview_actions_select]",$("#proinfo-listview-panel"));

        lis.off('click').on("click",function(e){
            var type =  $("#proHandleType").text();

            var this_li = $(this).parent();
            var id = $(this_li).attr("id");
//            var latitude=$("#latitude").val();
//            var longitude=$("#longitude").val();
            if(type=="feedback"){
                window.location.replace("ajax-proback!input.action?proInfoId="+id);
            }else if(type=="leave"){
                window.location.replace("ajax-proleave!input.action?proInfoId="+id);
            }else if(type=="signin"){
                //console.log("signin:" + id);
                $.mobile.loading( "show", {
                    text: "正在获取地理位置，请稍后...",
                    textVisible: true,
                    theme: "b",
                    textonly: false,
                    html: ""
                });
                getCheckInfo(id);
            }
        });
    });
    function getCheckInfo(id){
        wx.ready(function(){
            wx.getLocation({
                success: function (res) {
                    hide();
                    //var data = {keyId:id,latitude:res.latitude,longitude:res.longitude};
                    submitCheckInfo(id,res.latitude,res.longitude)
                },
                fail : function(){
                    hide();
                    alert("获取位置失败，请确认是否开启GPS定位功能!");
                }
            });
        });
    }
    function submitCheckInfo(id,latitude,longitude){
        $.mobile.loading( "show", {
            text: "正在保存，请稍后...",
            textVisible: true,
            theme: "b",
            textonly: false,
            html: ""
        });
        $.ajax({
            type: "POST",
            url: "ajax-proinfo!assign.action",
            cache:false,dataType:"json",
            data:{keyId:id,latitude:latitude,longitude:longitude},
            async:true,
            success: function(data){
                hide();
                if(data.result.errorCode == 404 || data.result.errorCode == "404"){
                    alert(data.result.errorMessage);
                }else{
                    alert(data.result.errorMessage);
                }
            },
            error: function(){
                hide();
            }
        });
    }
</script>



